/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo.DAL;

import java.sql.ResultSet;
import java.sql.Statement;
import org.json.JSONArray;
import org.json.JSONObject;

/**
 *
 * @author alb3rto
 */
public class Funcion_DAO {

    public static JSONArray consultarFunciones() {
        ConexionBD conex = new ConexionBD();
        JSONArray funciones = new JSONArray();

        try {
            Statement st = (Statement) conex.session.createStatement();

            ResultSet rs = st.executeQuery("SELECT id_funcion FROM funcion");
            int i = 0;
            while (rs.next()) {
                JSONObject funcion = new JSONObject();
                funcion.put("id_funcion", rs.getString(1));
                funciones.put(i++, funcion);
            }
        } catch (Exception e) {
            System.out.print("Error consultando Funciones: " + e.getMessage());
        } finally {
            if (conex != null) {
                conex.cerrarConexion();
            }
            return funciones;
        }
    }
}
